<template>
  <div class="birth-container">
    <van-datetime-picker
      v-model="currentDate"
      type="date"
      title="选择年月日"
      :min-date="minDate"
      :max-date="maxDate"
      @cancel="$emit('timefunc')"
      @confirm="onConfirm"
    />
    ==={{currentDate}}
  </div>
</template>
           
<script>
import  moment   from  'moment'
import { profile_api } from '@/api/profile.js'
export default {
  data() {
    return {
      minDate: new Date(2020, 0, 1),
      maxDate: new Date(2025, 11, 1),
      currentDate: new Date()
    }
  },
  methods: {
   async onConfirm(value) {
     // console.log(value,55566);
      //console.log(moment(this.currentDate).format('YYYY-MM-DD'),55566);
      //console.log(value,index, 8888)

      const { data: res } = await profile_api({
        birthday: moment(this.currentDate).format('YYYY-MM-DD')
      })
      console.log(res,4444);
      this.$emit('timefunc', res.data.birthday)
    }
  }
}
</script>
<style scoped>
</style>